#!/usr/bin/perl

($dir, $target, $num) = @ARGV;

&failed("can not chdir $dir $!") unless(chdir($dir));
&failed("$num <= 0") if($num <= 0);
$target =~ s|.*/||;

foreach $n ( 1 .. $num ){
	open(FILE, ">$n") || &failed("file $n can not created $!");
	print FILE "$target\n";
	print FILE "$num $n\n";
	close(FILE);
}
&success();

sub success {
	exit(0);
}
sub failed {
	#print(@_, "\n");
	exit(1);
}
